package project.model;

import java.io.Serializable;
import java.sql.ResultSet;

import model.pojo.Employee;
import models.util.MySqlDataAccessHelper;


public class PrComposition  implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4148139195033001478L;

	private String idComposition;
	private String idProject;
	private String idEmployee;
	private int position;
	private int status;
	private String userNameEmp;
	private String nameEmployee;
	private String positionEmployee;
	private boolean selected;
	private Employee eminfo= new Employee();
	private String db=null;
	private String statusName="";
	
	
	public String getStatusName() {
		return statusName;
	}

	public void setStatusName(String statusName) {
		this.statusName = statusName;
	}

	public String getDb() {
		return db;
	}

	public void setDb(String db) {
		this.db = db;
	}

	public Employee getEminfo(String dbc) {
		MySqlDataAccessHelper mysql =new MySqlDataAccessHelper();
		try{
			mysql.open(dbc);
			String sql="select employee.IDEmployee,employee.FullName " +
					"from employee " +
					"where employee.IDEmployee = '"+idEmployee+"'";
			ResultSet rs=mysql.executeQuery(sql);
			if(rs.next()){
				eminfo.setIdemployee(rs.getString("IDEmployee"));
				eminfo.setFullName(rs.getString("FullName"));
				//nameEmployee=rs.getString("FullName");
			}
			rs.close();
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			mysql.close();
		}
		return eminfo;
	}

	public void setEminfo(Employee eminfo) {
		this.eminfo = eminfo;
	}

	public boolean isSelected() {
		return selected;
	}

	public void setSelected(boolean selected) {
		this.selected = selected;
	}
	
	public PrComposition(){
		
	}
	
	public PrComposition(String idComposition, String idProject, String idEmployee, int position, int status) {
		this.idComposition = idComposition;
		this.idProject = idProject;
		this.idEmployee = idEmployee;
		this.position = position;
		this.status = status;
	}
	
	public PrComposition(String idComposition, String idProject, String idEmployee, int position, String userNameEmp, String nameEmployee,
			String positionEmployee,int status) {
		this.idComposition = idComposition;
		this.idProject = idProject;
		this.idEmployee = idEmployee;
		this.setNameEmployee(nameEmployee);
		this.position = position;
		this.status = status;
		this.positionEmployee = positionEmployee;
		this.userNameEmp = userNameEmp;
	}
	
	public PrComposition(String idComposition, String nameEmployee){
		this.idComposition=idComposition;
		this.nameEmployee=nameEmployee;
	}

	public String getIdComposition() {
		return idComposition;
	}

	public void setIdComposition(String idComposition) {
		this.idComposition = idComposition;
	}

	public String getIdProject() {
		return idProject;
	}

	public void setIdProject(String idProject) {
		this.idProject = idProject;
	}

	public String getIdEmployee() {
		return idEmployee;
	}

	public void setIdEmployee(String idEmployee) {
		this.idEmployee = idEmployee;
	}

	public int getPosition() {
		return position;
	}

	public void setPosition(int position) {
		this.position = position;
	}

	public void setNameEmployee(String nameEmployee) {
		this.nameEmployee = nameEmployee;
	}

	public String getNameEmployee() {
		return nameEmployee;
	}

	public void setPositionEmployee(String positionEmployee) {
		this.positionEmployee = positionEmployee;
	}

	public String getPositionEmployee() {
		return positionEmployee;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getStatus() {
		return status;
	}

	public void setUserNameEmp(String userNameEmp) {
		this.userNameEmp = userNameEmp;
	}

	public String getUserNameEmp() {
		return userNameEmp;
	}
	@Override
	public String toString() {
		return nameEmployee;
	}
}
